*************************************************************
*						NBIM ANALYSIS						*
*************************************************************

set more off
clear

*set path here
global CAPAPE "C:\Users\V.BERMEJO.B1\OneDrive - Universitat Ramón Llull\Escritorio\CAPAPE"
global outputtex "C:\Users\V.BERMEJO.B1\OneDrive - Universitat Ramón Llull\Escritorio\CAPAPE\tex"

*********************************************
*	Table IA.2: Summary stats holdings		*
*********************************************
preserve

use "$CAPAPE/DATA/Database_complete.dta", clear
sort ISIN year
collapse (sum) NBIM_holding_EqMV_USD, by(year) // NBIM holdings with Eikon data
export excel "$CAPAPE/tex/summary_stats/NBIM_Eikon_holdings.xlsx", replace


import excel "$CAPAPE\DATA\RAW_DATA\ALL_NBIM_master.xlsx", sheet("MV NBIM") firstrow clear // MV shows the market value holdings of NBIM 
rename Year year
drop if year < 2006
rename EQMarketValueNOK NBIM_holding_EqMV_NOK
rename EQMarketValueUSD NBIM_holding_EqMV_USD
gsort ISIN year -NBIM_holding_EqMV_USD // gsort to have descending order in sorting by NBIM and so duplicates drops the smallest value for NBIM holdings
*duplicates drop ISIN year, force // important to fix this to understand why there are duplicates, asked to Javier on 19-12 (48 observations)
collapse (sum) NBIM_holding_EqMV_USD, by(year) // NBIM holdings in NBIM original Excel
export excel "$CAPAPE/tex/summary_stats/NBIM_total_holdings.xlsx", replace
restore


use "$CAPAPE/DATA/Database_complete.dta", clear
rename excluded excluded_ethics
drop if ISIN == ""

* Clean data
replace Shares_perc_StrategicInvestors = 100 if Shares_perc_StrategicInvestors > 100 & Shares_perc_StrategicInvestors !=. // mail Javier 19-01 based on Wharton people commenting on this issue
gen outlier = (NBIM_holding_EqMV_USD < 0) | (ownership_NBIM < 0) // Set negative equity as outliers
replace NBIM_holding_EqMV_USD = 0 if NBIM_holding_EqMV_USD < 0 // Even if I call it outlier, I set it to zero as said by NBIM in Javier's email in June 8th 2017
replace ownership_NBIM = 0 if ownership_NBIM < 0
replace WtFTSEAllCapIndex = WtFTSEAllCapIndex*100 // It used to be in % (from 0 to 1), now it is from 0 to 100

* Fix years for regular analysis or for placebo test. Keep values always for regular analysis. To implement placebo, change values before section: regressions 
local MatchY = 2011 // It's the year prior to shock, matching year. Fix 2011 for normal analysis, and 2007 for placebo
local Event_year = 2012 // It's the year of the event. Fix 2012 for normal analysis, and 2008 for placebo
local maxYear = 2015 // It's the last year to be used for regressions. Fix 2015 for normal analysis, and 2011 for placebo

gen Post = (year >= 2012)
tab Country, gen (country_dummy)
forval i = 1/67 {
	gen Postcountry_dummy`i' = Post * country_dummy`i'
}
sort Country year
egen expand_var = mean(var), by(Country year)
replace var = expand_var
drop expand_var


* Adjust NAICS code to fewer groups
tostring NAICSInternationalIndustryCode, replace
gen NAICS_2digitcode = substr(NAICSInternationalIndustryCode,1,2)
destring NAICS_2digitcode, replace
gen NAICS_2digitname = "Agriculture, Forestry, Fishing and Hunting" if NAICS_2digitcode == 11
replace NAICS_2digitname = "Mining, Quarrying, and Oil and Gas Extraction" if NAICS_2digitcode == 21
replace NAICS_2digitname = "Utilities" if NAICS_2digitcode == 22
replace NAICS_2digitname = "Construction" if NAICS_2digitcode == 23
replace NAICS_2digitname = "Manufacturing" if NAICS_2digitcode == 31 | NAICS_2digitcode == 32 | NAICS_2digitcode == 33
replace NAICS_2digitname = "Wholesale Trade" if NAICS_2digitcode == 42
replace NAICS_2digitname = "Retail Trade" if NAICS_2digitcode == 44 | NAICS_2digitcode == 45
replace NAICS_2digitname = "Transportation and Warehousing" if NAICS_2digitcode == 48 | NAICS_2digitcode == 49
replace NAICS_2digitname = "Information" if NAICS_2digitcode == 51
replace NAICS_2digitname = "Finance and Insurance" if NAICS_2digitcode == 52
replace NAICS_2digitname = "Real Estate and Rental and Leasing" if NAICS_2digitcode == 53
replace NAICS_2digitname = "Professional, Scientific, and Technical Services" if NAICS_2digitcode == 54
replace NAICS_2digitname = "Management of Companies and Enterprises" if NAICS_2digitcode == 55
replace NAICS_2digitname = "Administrative, Support, Waste Management, Remediation Services" if NAICS_2digitcode == 56
replace NAICS_2digitname = "Educational Services" if NAICS_2digitcode == 61
replace NAICS_2digitname = "Health Care and Social Assistance" if NAICS_2digitcode == 62
replace NAICS_2digitname = "Arts, Entertainment, and Recreation" if NAICS_2digitcode == 71
replace NAICS_2digitname = "Accommodation and Food Services" if NAICS_2digitcode == 72
replace NAICS_2digitname = "Other Services (except Public Administration)" if NAICS_2digitcode == 81

* Create NBIM dummies (binary ownership for each year) and weights for firm & fund
sort ISIN year
forval i = 2006/2015 {
gen NBIM_in`i' = (NBIM == 1 & year == `i')
by ISIN: egen NBIM_`i' = max(NBIM_in`i')
drop NBIM_in`i'
}
by ISIN: gen NBIMt_1 = NBIM[_n-1]
gen treat = (NBIM_2011)


gen ManagementScorefix2011 = ManagementScore if year == 2011
gen TotalAssetsfix2011 = TotalAssets if year == 2011
by ISIN: egen ManagementScore2011 = max(ManagementScorefix2011)
by ISIN: egen TotalAssets2011 = max(TotalAssetsfix2011)
drop ManagementScorefix2011 TotalAssetsfix2011

* FTSE 
sort ISIN year
gen FTSE = (WtFTSEAllCapIndex != .)
by ISIN: gen FTSEt_1 = FTSE[_n-1]
gen FTSEyes_NBIMno = (FTSE == 1 & NBIM == 0)
gen FTSEno_NBIMYES = (FTSE == 0 & NBIM == 1)
forval i = 2006/2014 {
gen FTSE_in`i' = (FTSE == 1 & year == `i')
by ISIN: egen FTSE_`i' = max(FTSE_in`i')
drop FTSE_in`i'
}

* Generate variables
sort ISIN year
gen performance =  EBITDA / TotalAssets
gen ROA = NetIncomeBeforeTaxes / TotalAssets
gen logAssets = log(TotalAssets)
by ISIN: gen performancet_1 = performance[_n-1]
gen CapitalStructure = TotalLiabilities/TotalEquity
gen LTDebtoverTotalLiabs = TotalLongTermDebt / TotalLiabilities
gen EBITDAoverRevenue = EBITDA / TotalRevenue
gen EBIToverRevenue = EBIT / TotalRevenue
gen Institutional_investors_total = BankandTrust + BrokerageFirms + Corporation + EndowmentFund + Foundation + GovernmentAgency + HedgeFund + HedgeFundPortfolio + HoldingCompany + IndependentResearchFirm + IndividualInvestor + InsuranceCompany + InvestmentAdvisor + InvestmentAdvisorHedgeFund + MutualFund + OtherInsiderInvestor + PensionFund + PensionFundPortfolio + PrivateEquity + ResearchFirm + SovereignWealthFund + TreasuryShares + VentureCapital
replace Institutional_investors_total = 100 if Institutional_investors_total > 100 & Institutional_investors_total != . // & Institutional_investors_total <= 105 // mail Javier 19-01 based on Wharton people commenting on this issue
replace TotalAssets = TotalAssets/1000000000
replace TotalRevenue = TotalRevenue/1000000000 
gen age2011 = 2011 - DateofIncorporation
replace age2011 = 0 if age2011 < 0


* Create outliers for SCORE data since there is strong attrition and there are many missing values at the beggining of the sample. Force our data to have nonmissing values from 2009 to avoid attrition bias
sort ISIN year
gen outlierSCOREall = 1 if ManagementScore == . & year >= 2009 // All SCORE values have the same missing values
by ISIN: egen outlierSCORE = max(outlierSCOREall)
replace outlierSCORE = 0 if outlierSCORE == . // outlierScore = 1 if firm has any missing values for the Score after 2009
drop outlierSCOREall


*****************************************************************
*		 	Create governance index in levels					*
*****************************************************************

* Set Management Index provisions between 0 and 1
replace AuditCommitteeIndep = AuditCommitteeIndep/100
replace BoardMeetingAttendanceAvg = BoardMeetingAttendanceAvg/100
replace BoardSpecificSkills = BoardSpecificSkills/100
replace CompensationCommitteeIndep = CompensationCommitteeIndep/100
replace FemaleonBoard = FemaleonBoard/100
replace IndependentBoardMembers = IndependentBoardMembers/100
replace NominationCommitteeIndep = NominationCommitteeIndep/100
replace NominationCommitteeInvolv = NominationCommitteeInvolv/100
replace NonExecutiveBoardMembers = NonExecutiveBoardMembers/100
replace ExecutivsGenderDiversPerc = ExecutivsGenderDiversPerc/100
replace ExperienceBoard  = ExperienceBoard/36

* Provisions with negative polarity for Managem Index:
replace CEOChairmanSeparation = 1-CEOChairmanSeparation
replace BoardMemberAffiliations = 1-(BoardMemberAffiliations/19) 
replace BoardSizeMore10Less8 = 1-(BoardSizeMore10Less8/34) 

bysort NAICS_2digitname year: egen maxHighestRemunerationPackag = max(HighestRemunerationPackag)
bysort NAICS_2digitname year: egen minHighestRemunerationPackag = min(HighestRemunerationPackag)
replace HighestRemunerationPackag = 1-((HighestRemunerationPackag-minHighestRemunerationPackag) / (maxHighestRemunerationPackag-minHighestRemunerationPackag)) //standardized between 0 & 1
drop minHighestRemunerationPackag maxHighestRemunerationPackag

bysort NAICS_2digitname year: egen maxTotalSeniorExecCompens = max(TotalSeniorExecCompens)
bysort NAICS_2digitname year: egen minTotalSeniorExecCompens = min(TotalSeniorExecCompens)
replace TotalSeniorExecCompens = 1-((TotalSeniorExecCompens-minTotalSeniorExecCompens) / (maxTotalSeniorExecCompens-minTotalSeniorExecCompens)) //standardized between 0 & 1
drop minTotalSeniorExecCompens maxTotalSeniorExecCompens

* To create index in levels (equally weighted index)
egen ManagementIndex = rowtotal(auditcommitteemgtindep  AuditCommitteeIndep BoardAttendance BoardBackgroundandSkills BoardCulturalDiversity BoardFunctionsPolicy ///
	BoardIndividualReelection BoardMeetingAttendanceAvg BoardMemberAffiliations BoardSizeMore10Less8 BoardSpecificSkills BoardStructurePolicy CEOCompensatLinktoTSR ///
	CEOChairmanSeparation CompensationCommitteeIndep CompensCommittMgtIndep CompensationImprovTools ExecutiveCompensPolicy ExecutiveIndivCompens FemaleonBoard ///
	IndependentBoardMembers InternalAuditDepartReport NominationCommitteeIndep NominationCommitteeInvolv NonExecutiveBoardMembers SharehApprovalStockComp ExecutivsGenderDiversPerc ///
	SuccessionPlan SustainabCompensIncentives executivecompensationltobj ExperienceBoard ExternalConsultants HighestRemunerationPackag TotalSeniorExecCompens), missing  

egen Indexnonmissing =  rownonmiss(auditcommitteemgtindep  AuditCommitteeIndep BoardAttendance BoardBackgroundandSkills BoardCulturalDiversity BoardFunctionsPolicy ///
	BoardIndividualReelection BoardMeetingAttendanceAvg BoardMemberAffiliations BoardSizeMore10Less8 BoardSpecificSkills BoardStructurePolicy CEOCompensatLinktoTSR ///
	CEOChairmanSeparation CompensationCommitteeIndep CompensCommittMgtIndep CompensationImprovTools ExecutiveCompensPolicy ExecutiveIndivCompens FemaleonBoard ///
	IndependentBoardMembers InternalAuditDepartReport NominationCommitteeIndep NominationCommitteeInvolv NonExecutiveBoardMembers SharehApprovalStockComp ExecutivsGenderDiversPerc ///
	SuccessionPlan SustainabCompensIncentives executivecompensationltobj ExperienceBoard ExternalConsultants HighestRemunerationPackag TotalSeniorExecCompens) // Add all existing (nonmissing) provisions to use as denominator in equally weighted index

replace ManagementIndex = (ManagementIndex / Indexnonmissing)*100 // Equally weighted sum of the existing (nonmissing) provisions that the company has, index is between 0 and 100
replace ManagementIndex = . if Indexnonmissing < 32 // Drop Management Score for firms that have less than "x" of nonmissing provisions. If its <32, puede tener 3 missing provisions


* Create Indexes related to NBIM Note
egen IndexNBIMyes = rowtotal(BoardAttendance BoardBackgroundandSkills BoardCulturalDiversity BoardFunctionsPolicy BoardIndividualReelection BoardMemberAffiliations ///
	BoardSpecificSkills CEOCompensatLinktoTSR CEOChairmanSeparation executivecompensationltobj ExperienceBoard IndependentBoardMembers SuccessionPlan), missing
egen IndexNBIMyesMiss = rownonmiss(BoardAttendance BoardBackgroundandSkills BoardCulturalDiversity BoardFunctionsPolicy BoardIndividualReelection BoardMemberAffiliations ///
	BoardSpecificSkills CEOCompensatLinktoTSR CEOChairmanSeparation executivecompensationltobj ExperienceBoard IndependentBoardMembers SuccessionPlan)
	
egen IndexNBIMunclear = rowtotal(AuditCommitteeIndep auditcommitteemgtindep BoardMeetingAttendanceAvg BoardStructurePolicy CompensationImprovTools ExecutiveCompensPolicy ///
	FemaleonBoard NominationCommitteeInvolv SustainabCompensIncentives), missing
egen IndexNBIMunclearMiss = rownonmiss(AuditCommitteeIndep auditcommitteemgtindep BoardMeetingAttendanceAvg BoardStructurePolicy CompensationImprovTools ExecutiveCompensPolicy ///
	FemaleonBoard NominationCommitteeInvolv SustainabCompensIncentives)
	
egen IndexNBIMNo = rowtotal(BoardSizeMore10Less8 CompensationCommitteeIndep CompensCommittMgtIndep ExecutiveIndivCompens ExternalConsultants HighestRemunerationPackag ///
	InternalAuditDepartReport NominationCommitteeIndep NonExecutiveBoardMembers SharehApprovalStockComp TotalSeniorExecCompens ExecutivsGenderDiversPerc), missing
egen IndexNBIMNoMiss = rownonmiss(BoardSizeMore10Less8 CompensationCommitteeIndep CompensCommittMgtIndep ExecutiveIndivCompens ExternalConsultants HighestRemunerationPackag ///
	InternalAuditDepartReport NominationCommitteeIndep NonExecutiveBoardMembers SharehApprovalStockComp TotalSeniorExecCompens ExecutivsGenderDiversPerc)

replace IndexNBIMyes = (IndexNBIMyes/IndexNBIMyesMiss)*100
replace IndexNBIMunclear = (IndexNBIMunclear/IndexNBIMunclearMiss)*100
replace IndexNBIMNo = (IndexNBIMNo/IndexNBIMNoMiss)*100

replace IndexNBIMyes = . if Indexnonmissing < 32 // As for Management Index in levels, to have homogenous sample, we drop Score for firms that have less than 32 of nonmissing provisions. If its <32, puede tener 3 missing provisions
replace IndexNBIMunclear = . if Indexnonmissing < 32 // As for Management Index in levels, to have homogenous sample, we drop Score for firms that have less than 32 of nonmissing provisions. If its <32, puede tener 3 missing provisions
replace IndexNBIMNo = . if Indexnonmissing < 32 // As for Management Index in levels, to have homogenous sample, we drop Score for firms that have less than 32 of nonmissing provisions. If its <32, puede tener 3 missing provisions

gen indexNBIM = ManagementScore // ManagementScore ShareholdersScore
label var indexNBIM "NBIM Governance Index"


* Make vars of CG indexes fixed for years 2011 and 2012
sort ISIN year
encode ISIN, gen (ISINnumeric)
tsset ISINnumeric year
tssmooth ma indexNBIMma2=indexNBIM, window(1 1 0)
tssmooth ma indexNBIMma2l1=indexNBIM, window(2 0 0)
tssmooth ma indexNBIMma3=indexNBIM, window(2 1 0)
sort ISIN year
foreach year of numlist 2009/2015 {
	gen indexNBIMfix`year' = indexNBIM if year == `year'
	by ISIN: egen indexNBIMfixed`year' = max(indexNBIMfix`year')
	gen ShareholdersScorefix`year' = ShareholdersScore if year == `year'
	by ISIN: egen ShareholdersScorefixed`year' = max(ShareholdersScorefix`year')
	gen ManagementScorefix`year' =  ManagementScore if year == `year'
	by ISIN: egen ManagementScorefixed`year' = max(ManagementScorefix`year')
}
drop indexNBIMfix2* ManagementScorefix2* ShareholdersScorefix2*  

* Make vars NBIM_firm_perc & NBIM_fund_perc
replace NBIM_holding_EqMV_USD = 0 if missing(NBIM_holding_EqMV_USD)
gen NBIM_firm_perc = (NBIM_holding_EqMV_USD / MV ) * 100 if outlier == 0 // de 0 a 100; shows the % that the NBIM has of the firm's MV. MV puede ser missing porque la empresa no cotizaba aun, pero NBIM holding no será missing porque hago replace missing = 0 en la fila de arriba
gen FTSE_firm_perc = FTSEMktCapUSDafterinvestib*1000 / MV if outlier == 0 
gen MVfix2010 = MV if year == 2010
sort ISIN year
by ISIN: egen MV2010 = max(MVfix2010)
gen NBIM_firm_percMV2010 = (NBIM_holding_EqMV_USD / MV2010 ) * 100 // de 0 a 100; shows the % that the NBIM has of the firm's MV. MV puede ser missing porque la empresa no cotizaba aun, pero NBIM holding no será missing porque hago replace missing = 0 en la fila de arriba
gen outlierweight = (NBIM_firm_percMV2010>20)
by ISIN: egen NBIM_atanyyear = max(NBIM) // NBIM_atanyyear = 1 if the firm is ever a holding by NBIM

sort year ISIN
by year: egen total_NBIM_year = total (NBIM_holding_EqMV_USD) if outlier == 0
gen total_NBIM_fix2010 = total_NBIM_year if year == 2010
sort ISIN year
by ISIN: egen total_NBIM_2010 = max(total_NBIM_fix2010)
gen NBIM_fund_perc = (NBIM_holding_EqMV_USD / total_NBIM_year) * 100 if outlier == 0 // de 0 a 100; shows the % that the firm represents on the NBIM fund's total holdings per year. El máximo es 2% que significa que la firma representa el 2% de todos los holdings del fund.
gen NBIM_fund_percMV2010 = (NBIM_holding_EqMV_USD / total_NBIM_2010) * 100 if outlier == 0 // de 0 a 100; shows the % that the firm represents on the NBIM fund's total holdings in 2010. El máximo es 2.7% que significa que la firma representa el 2.7% de todos los holdings del fund.

sort year ISIN
by year: egen total_NBIM_portfolio2010 = total (NBIM_holding_EqMV_USD) if outlier == 0 & NBIM_2010 == 1 // total MV of NBIM portfolio, for firms in their portfolio in 2010, 
gen NBIM_fund_perc_portf2010 = (NBIM_holding_EqMV_USD / total_NBIM_portfolio2010) * 100 if outlier == 0 & NBIM_2010 == 1 // firms not in the portfolio in 2010 will be missing and not used in calculations. de 0 a 100; shows the % that the firm represents on the NBIM fund's total holdings in the portfolio NBIM had in 2010. El máximo es 2.15% que significa que la firma representa el 2.15% de todos los holdings del fund.
drop total_NBIM_year total_NBIM_fix2010 total_NBIM_2010
gen NBIM_firm_perc_pf2010 = (NBIM_holding_EqMV_USD / MV2010) * 100 if outlier == 0 & NBIM_2010 == 1

* Make vars of weights fixed for 2011
sort ISIN year
gen NBIM_fund_perc_pf2010 = NBIM_fund_perc_portf2010 
rename WtFTSEAllCapIndex FTSE_perc
replace FTSE_perc = 0 if FTSE_perc == .
local VARS = "NBIM_firm_perc NBIM_fund_perc FTSE_perc NBIM_fund_percMV2010 NBIM_firm_percMV2010 NBIM_fund_perc_pf2010 NBIM_firm_perc_pf2010"
foreach var of local VARS {
	gen `var'fix2011 = `var' if year == 2011
	by ISIN: egen `var'fixed2011 = max(`var'fix2011)
	drop `var'fix2011
}
gen NBIM_holding_fix2011 = NBIM_holding_EqMV_USD if year == 2011 
by ISIN: egen NBIM_holding_fixed2011 = max(NBIM_holding_fix2011)
gen int_NBIM_holding_fixed2011 = int(NBIM_holding_fixed2011) // to include fixed weights in regressions
drop NBIM_holding_fix2011
by ISIN: gen NBIM_firm_perct_1=NBIM_firm_perc[_n-1]


* Remove zeros from FTSE_perc NBIM_firm_perc and NBIM_fund_perc
sort ISIN year
gen FTSE_perc_nozeros = (FTSE_perc)
replace FTSE_perc_nozeros = . if FTSE_perc == 0
gen NBIM_firm_perc_nozeros = (NBIM_firm_perc)
replace NBIM_firm_perc_nozeros = . if NBIM_firm_perc == 0
gen NBIM_fund_perc_nozeros = (NBIM_fund_perc)
replace NBIM_fund_perc_nozeros = . if NBIM_fund_perc == 0

gen FTSE_percfixed2011nozero = (FTSE_percfixed2011)
replace FTSE_percfixed2011nozero = . if FTSE_percfixed2011 == 0
gen NBIM_firm_percfixed2011nozero = NBIM_firm_percfixed2011
replace NBIM_firm_percfixed2011nozero = . if NBIM_firm_percfixed2011 == 0
gen NBIM_fund_percfixed2011nozero = NBIM_fund_percfixed2011
replace NBIM_fund_percfixed2011nozero = . if NBIM_fund_percfixed2011 == 0

encode ISIN, gen(id)


*************************************************************************
*					 SUMMARY STATISTICS 								*
*************************************************************************

sort ISIN year
by ISIN: gen ManagementScorechangef1 = (ManagementScore[_n+1] - ManagementScore)
by ISIN: gen ManagementScorechangef1abs = abs(ManagementScore[_n+1] - ManagementScore)

*********************************
* Table 2: Summary Statistics	*
*********************************

global vars ManagementScore NBIM_fund_perc NBIM_firm_perc ManagementScorechangef1 ManagementScorechangef1abs 
eststo: quietly estpost tabstat $vars if outlier == 0 & year >= 2009 & outlierSCORE == 0, stat(mean sd p25 p50 p75 count) col(stat) 
esttab , cells("mean(fmt(4)) sd(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0))") 
esttab using "$outputtex/tables/SumStats1.doc", replace cells("mean(fmt(4)) sd(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0))") ///
compress mtitle("Summary Statistics") unstack nogap nonumber not noobs label 
eststo clear


*****************************************************************
* Table IA.3 Summary statistics for Non NBIM and NBIM firms 	*
*****************************************************************

local SUMVARS = "indexNBIM TotalRevenue TotalAssets CapitalStructure EBITDAoverRevenue ROA Institutional_investors_total"

* Sum Stats for the period 2010-2011	
tabstat `SUMVARS', by(treat) statistics(mean sd) columns(statistics) nototal
estpost sum `SUMVARS' if treat == 0 & year >2009 & year <2012  & outlier == 0 & outlierSCORE == 0 
est store A`year'
estpost sum `SUMVARS' if treat == 1 & year >2009 & year <2012  & outlier == 0 & outlierSCORE == 0 
est store B`year'
* Ttest for difference in means unmatched
estpost ttest `SUMVARS' if year >2009 & year <2012 & outlier == 0 & outlierSCORE == 0, by(treat) unequal 
est store TA`year'
	
esttab A`year' B`year' using "$outputtex/summary_stats/tableSUMVARSpaper_avg10y11.rtf", replace ///
	mtitle("NBIM=0" "NBIM=1") ///
	cells((mean(fmt(2))) sd(fmt(2)par)) label collabels(none) stats(N, fmt(0) labels("Observations")) 
		
esttab TA`year' using "$outputtex/summary_stats/tableSUMVARS_ttestpaper_avg10y11.rtf", replace ///
	mtitle("Mean differences") ///
	label nonotes collabels(none) noobs stats(N, fmt(0) labels("Observations"))	

* Correction of T-value (significance stars) from T-test (T-value comes from 2 sided test, so it's too high)
foreach var of local SUMVARS {
	reg `var' treat if year >2009 & year <2012  & outlier == 0 & outlierSCORE == 0, vce(cl id)
}


*****************************************************************
* 	Table IA.4 and IA.5 Summary Stats for industry and country 	*
*****************************************************************
tab NAICS_2digitname NBIM if year == 2011
tab Country NBIM if year == 2011



*********************************************************************
*				 Table 1: Analysis of investor types 				*
*********************************************************************

* Thomson Reuters Database Database_complete
* Merge some groups (there are too many)
gen Big3 = HoldingCompany + InvestmentAdvisorHedgeFund
gen PensionFunds = PensionFund + PensionFundPortfolio
gen HedgeFunds = HedgeFund + HedgeFundPortfolio
gen OtherInvestmentManagers= BankandTrust + EndowmentFund + Foundation + InvestmentAdvisor + InsuranceCompany + PrivateEquity + VentureCapital
gen BrokerageFirm = ResearchFirm + IndependentResearchFirm
gen StrategicEntities =  GovernmentAgency + TreasuryShares + OtherInsiderInvestor
gen OtherSmallInvestors = OtherInvestmentManagers + BrokerageFirm + StrategicEntities + MutualFund
gen OtherBigInvestors = Corporation + IndividualInvestor + InvestmentAdvisor

label var OtherBigInvestors "Corporations, Individual Ivestors & Asset Managers"

local SUMVARS = "Big3 PensionFunds SovereignWealthFund HedgeFunds OtherBigInvestors OtherSmallInvestors Institutional_investors_total"

foreach var in `SUMVARS'{
	replace `var' = 100 if `var' > 100 & `var'!=. 
}

* We do ownership analysis for NBIM vs non-NBIM
foreach year of numlist 2011 {
		tabstat `SUMVARS', by(treat) statistics(mean sd) columns(statistics) nototal
		estpost sum `SUMVARS' if treat == 0 & year == `year'  & outlier == 0 & outlierSCORE == 0 
		est store A`year'
		estpost sum `SUMVARS' if treat == 1 & year == `year'  & outlier == 0 & outlierSCORE == 0 
		est store B`year'
		* Ttest for difference in means unmatched
		estpost ttest `SUMVARS' if year == `year' & outlier == 0 & outlierSCORE == 0, by(treat) unequal 
		est store TA`year'
		
		esttab A`year' B`year' using "$outputtex/summary_stats/tableOwners_`year'.rtf", replace ///
			mtitle("NBIM=0" "NBIM=1") ///
			cells((mean(fmt(2))) sd(fmt(2)par)) label collabels(none) stats(N, fmt(0) labels("Observations")) order (Big3 PensionFunds SovereignWealthFund HedgeFunds OtherBigInvestors OtherSmallInvestors Institutional_investors_total )
		
		esttab TA`year' using "$outputtex/summary_stats/tableOwners_ttest`year'.rtf", replace ///
			mtitle("Mean differences") ///
			cells((b(fmt(2)star)) se(fmt(2)par)) label nonotes collabels(none) noobs stats(N, fmt(0) labels("Observations")) order (Big3 PensionFunds SovereignWealthFund HedgeFunds OtherBigInvestors OtherSmallInvestors Institutional_investors_total)		
}



*********************************************************	
*		OVERALL ANALYSIS: ENDOGENOUS REGRESSIONS 		*
*********************************************************

* Create interactions with Post
replace Post = (year >= 2012) // `Event_year' or 2013
gen Posttreat = Post * treat 
gen PostNBIM_firm_perc = Post * NBIM_firm_perc
gen PostNBIM_fund_perc = Post * NBIM_fund_perc
gen PostNBIM_firm_perc_nozeros = Post * NBIM_firm_perc_nozeros
gen PostNBIM_fund_perc_nozeros = Post * NBIM_fund_perc_nozeros
gen PostNBIM_firm_percfixed2011 = Post * NBIM_firm_percfixed2011
gen PostNBIM_fund_percfixed2011 = Post * NBIM_fund_percfixed2011
gen PostNBIM_firm_fix2011nozero = Post * NBIM_firm_percfixed2011nozero
gen PostNBIM_fund_fix2011nozero = Post * NBIM_fund_percfixed2011nozero

gen PostManagementScorefixed2011 = Post * ManagementScorefixed2011
gen PostShareholdersScorefixed2011 = Post * ShareholdersScorefixed2011


* To set reference year
local refyear = 2009 // set 2006 for robustness tests of trends
local maxYear = 2015
gen outlieryeardummies = (year < `refyear') | (year > `maxYear')
forval i = 2006/`maxYear' {
	gen yeardummy`i' = (year == `i')
	gen Treat_yeardummy`i' = treat * yeardummy`i'
	gen NBIM_2010_yeardummy`i' = NBIM_2010 * yeardummy`i'
	gen NBIM_firm_perc_yeardummy`i' = NBIM_firm_perc * yeardummy`i'
	gen NBIM_firm_perc2011_year`i' = NBIM_firm_percfixed2011 * yeardummy`i'
	gen NBIM_firm_perc_nozeros_year`i' = NBIM_firm_perc_nozeros * yeardummy`i'
	gen NBIM_firm_2011nozero_year`i' = NBIM_firm_percfixed2011nozero * yeardummy`i'
	gen NBIM_fund_perc_yeardummy`i' = NBIM_fund_perc * yeardummy`i'
	gen NBIM_fund_perc2011_year`i' = NBIM_fund_percfixed2011 * yeardummy`i'
	gen NBIM_fund_perc_nozeros_year`i' = NBIM_fund_perc_nozeros * yeardummy`i'
	gen NBIM_fund_2011nozero_year`i' = NBIM_fund_percfixed2011nozero * yeardummy`i'
}

* Label vars
label var treat "NBIM"
label var Posttreat "Post*NBIM"
label var NBIM_firm_perc "NBIM_firm(%)"
label var NBIM_firm_perc_nozeros "NBIM_firm(%)no0"
label var NBIM_fund_perc "NBIM_fund(%)"
label var NBIM_fund_perc_nozeros "NBIM_fund(%)no0"
label var PostNBIM_firm_perc "Post*NBIMfirm(%)"
label var PostNBIM_firm_percfixed2011 "Post*NBIMfirm(%)2011"
label var PostNBIM_firm_perc_nozeros "Post*NBIMfirmno0(%)"
label var PostNBIM_firm_fix2011nozero "Post*NBIMfirm2011no0"
label var PostNBIM_fund_perc "Post*NBIMfund(%)"
label var PostNBIM_fund_percfixed2011 "Post*NBIMfund(%)2011"
label var PostNBIM_fund_perc_nozeros "Post*NBIMfundno0(%)"
label var PostNBIM_fund_fix2011nozero "Post*NBIMfund2011(%)no0"

forval i = 2007/`maxYear' {
	label var Treat_yeardummy`i' "NBIM*yeardummy`i'"
	label var NBIM_fund_perc_yeardummy`i' "Fund(%)*year`i'"
	label var NBIM_firm_perc_yeardummy`i' "Firm(%)*year`i'"
}

xtset id year
local KEEP_VARS "NBIM NBIM_firm_perc NBIM_fund_perc PostNBIM_fund_perc PostNBIM_firm_perc NBIM_fund_perc_yeardummy* NBIM_firm_perc_yeardummy*"
local SORT_VARS "NBIM NBIM_firm_perc NBIM_fund_perc PostNBIM_fund_perc PostNBIM_firm_perc NBIM_fund_perc_yeardummy* NBIM_firm_perc_yeardummy*"
local YLISTSCORES "ManagementScore" 


*********************************************************************
* Table 3. Governance differences among NBIM and non-NBIM firms		*
*********************************************************************

* We impose full panel for the Mg. Score (by setting outlierSCORE == 0) to have the same firms each year, given that our dep variable is Mg. Score and it changes every year
foreach Y of local YLISTSCORES {
	quietly reg `Y' NBIM if year == 2007 & outlier == 0 & outlierSCORE == 0
	outreg2 using "$outputtex/tables/CSrolling_`Y'.doc", replace nocons tex(frag) label ctitle("2007") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
	
	foreach year of numlist 2007/2015 {
		reg `Y' NBIM if year == `year' & outlier == 0 & outlierSCORE == 0 
		outreg2 using "$outputtex/tables/CSrolling_`Y'.doc", nocons tex(frag) label ctitle("`year'") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
	}
}


*****************************************************************
* Table IA.6 Governance differences among fund and firm weights	*
*****************************************************************

local KEEP_VARS "NBIM* Post*"
local SORT_VARS "NBIM_fund_perc PostNBIM_fund_perc NBIM_firm_perc PostNBIM_firm_perc"

quietly reg ManagementScore NBIM_fund_perc PostNBIM_fund_perc yeardummy* if outlier == 0 & outlierSCORE == 0
outreg2 using "$outputtex/tables/preliminaryManag.doc", replace nocons tex(frag) label ctitle("Fund") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
quietly reg ManagementScore NBIM_firm_perc PostNBIM_firm_perc yeardummy* if outlier == 0 & outlierSCORE == 0
outreg2 using "$outputtex/tables/preliminaryManag.doc", nocons tex(frag) label ctitle("Firm") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)




*****************************************************************************	
*	DECOMPOSITION: Effect on NBIM investment strategy - entry & exit		*
*****************************************************************************

local refyear = 2009
replace yeardummy`refyear' = 0
replace Treat_yeardummy`refyear' = 0 
replace NBIM_firm_perc_yeardummy`refyear' = 0 
replace NBIM_firm_perc2011_year`refyear' = 0 
replace NBIM_firm_2011nozero_year`refyear' = 0
replace NBIM_fund_perc_yeardummy`refyear' = 0 
replace NBIM_fund_perc2011_year`refyear' = 0 
replace NBIM_fund_2011nozero_year`refyear' = 0

* FTSE entry definitions
sort ISIN year
by ISIN: gen FTSE_entry = (FTSE == 1 & FTSE[_n-1]== 0)
by ISIN: gen FTSE_exit = (FTSE == 0 & FTSE[_n-1]== 1) 
by ISIN: gen FTSE_entry2 = (FTSE == 1 & FTSE[_n-1]== 0) | (FTSE[_n-1] == 1 & FTSE[_n-2]== 0)
by ISIN: gen FTSE_exit2 = (FTSE == 0 & FTSE[_n-1]== 1) | (FTSE[_n-1] == 0 & FTSE[_n-2]== 1)
by ISIN: gen FTSE_entry2_before = (FTSE[_n+1] == 1 & FTSE== 0) | (FTSE == 1 & FTSE[_n-1]== 0)
by ISIN: gen FTSE_exit2_before = (FTSE[_n+1] == 0 & FTSE== 1) | (FTSE == 0 & FTSE[_n-1]== 1)

* For Portfolio analaysis and alphas:
by ISIN: gen NBIMportf_entry = 1 if NBIM == 1 & NBIM[_n-1] == 0 & FTSE_entry2 != 1 // exiges que en dic de t-1 no estuviera, y que entre en algun punto del año t.
by ISIN: gen NBIMportf_exit = 1 if NBIM == 0 & NBIM[_n-1] == 1  // exiges que NBIM salga en algun punto del año t.
by ISIN: replace NBIMportf_exit = . if FTSE_exit2 == 1  | excluded_ethics == 1
by ISIN: gen NBIMportf_entry_after = 1 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n-2] == 0 & FTSE != 1 // exiges que en dic de t-1 estuviera, que esté en todo t, y que no estuviera en dic t-2. NBIM entró en algun punto de t-1. Será 1 en todo t. NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n-2] == 0 o NBIM == 1 & NBIM[_n-1] == 0
by ISIN: gen NBIMportf_entry_before = 1 if NBIM[_n+1] == 1 & NBIM == 0 & FTSE_entry2_before != 1 // & FTSE[_n+1] != 1 
by ISIN: gen NBIMportf_exit_after = 1 if NBIM == 0 & NBIM[_n-2] == 1  //  NBIM == 0 & NBIM[_n-1] == 0 & NBIM[_n-2] == 1 o NBIM == 0 & NBIM[_n-1] == 1
by ISIN: replace NBIMportf_exit_after = . if FTSE == 0 & FTSE[_n-2] == 1  | excluded_ethics == 1 // & FTSE[_n-2] == 1  | excluded_ethics == 1 // & FTSE[_n-2] == 1 | excluded_ethics == 1
by ISIN: gen NBIMportf_exit_after2 = 1 if NBIM == 0 & NBIM[_n-1] == 0 & NBIM[_n-2] == 1  //  NBIM == 0 & NBIM[_n-1] == 0 & NBIM[_n-2] == 1 o NBIM == 0 & NBIM[_n-1] == 1
by ISIN: replace NBIMportf_exit_after2 = . if FTSE == 0 & FTSE[_n-1] == 0 & FTSE[_n-2] == 1  | excluded_ethics == 1 // & FTSE[_n-2] == 1 | excluded_ethics == 1

by ISIN: gen NBIMportf_exit_before = 1 if NBIM[_n+1] == 0 & NBIM == 1 // & NBIM[_n-1] == 1
by ISIN: replace NBIMportf_exit_before = . if  FTSE_exit2_before == 1 | excluded_ethics == 1 // FTSE == 1 | excluded_ethics[_n+1] == 1
by ISIN: gen ManagementScore_n_1 = ManagementScore[_n-1]
by ISIN: gen ManagementScore_n_2 = ManagementScore[_n-2]

* Generate NBIMyear which takes value 1 if firm is NBIM in that year or 0 otherwise
foreach year of numlist 2006/2015 {
gen NBIM`year'prueba = 1 if NBIM == 1 & year == `year'
by ISIN: egen NBIM`year' = max(NBIM`year'prueba)
replace NBIM`year' = 0 if NBIM`year' == .
drop NBIM`year'prueba
}
tab NBIM2012 NBIM2013 if year == 2012 // 279 firms are not in NBIM in 2012 but are included in 2013; 60 firms are NBIM in 2012 but are removed in 2013
tab year NBIM 


* Entries
by ISIN: gen NBIM_entry_vs_nonNBIM = 1 if NBIM == 1 & NBIM[_n-1] == 0 
gen NBIM_entry = NBIM_entry_vs_nonNBIM
by ISIN: replace NBIM_entry_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0 & NBIM[_n-2] == 0  
gen NBIMnoFTSE_entry_vs_nonNBIM = NBIM_entry_vs_nonNBIM
replace NBIMnoFTSE_entry_vs_nonNBIM = . if FTSE_entry2 == 1 
gen NBIMyFTSE_entry_vs_nonNBIM = 1 if FTSE_entry2 == 1 & NBIM_entry_vs_nonNBIM == 1  
by ISIN: replace NBIMnoFTSE_entry_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0 & NBIM[_n-2] == 0  
by ISIN: replace NBIMyFTSE_entry_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0 & NBIM[_n-2] == 0  

gen NBIM_entry_vs_NBIM = 1 if NBIM_entry_vs_nonNBIM == 1
gen NBIMnoFTSE_entry_vs_NBIM = NBIM_entry_vs_NBIM
by ISIN: replace NBIM_entry_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1 
replace NBIMnoFTSE_entry_vs_NBIM = . if FTSE_entry2 == 1 
gen NBIMyFTSE_entry_vs_NBIM = 1 if FTSE_entry2 == 1 & NBIM_entry_vs_NBIM == 1  
by ISIN: replace NBIMnoFTSE_entry_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1  
by ISIN: replace NBIMyFTSE_entry_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1 

gen NBIM_entry_vs_ALL = 1 if NBIM_entry_vs_nonNBIM == 1
gen NBIMnoFTSE_entry_vs_ALL = NBIM_entry_vs_ALL
replace NBIM_entry_vs_ALL = 0 if NBIM_entry_vs_NBIM == 0 | NBIM_entry_vs_nonNBIM == 0 
replace NBIMnoFTSE_entry_vs_ALL = . if FTSE_entry2 == 1 
gen NBIMyFTSE_entry_vs_ALL = 1 if FTSE_entry2 == 1 & NBIM_entry_vs_ALL == 1  
replace NBIMnoFTSE_entry_vs_ALL = 0 if NBIM_entry_vs_NBIM == 0 | NBIM_entry_vs_nonNBIM == 0 
replace NBIMyFTSE_entry_vs_ALL = 0 if NBIM_entry_vs_NBIM == 0 | NBIM_entry_vs_nonNBIM == 0 

* Exits
by ISIN: gen NBIM_exit_vs_nonNBIM = 1 if NBIM == 0 & NBIM[_n-1] == 1 
gen NBIM_exit = NBIM_exit_vs_nonNBIM
by ISIN: replace NBIM_exit_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0  & NBIM[_n-2] == 0 
gen NBIMnoFTSE_exit_vs_nonNBIM = NBIM_exit_vs_nonNBIM
replace NBIMnoFTSE_exit_vs_nonNBIM = . if FTSE_exit2 == 1 
gen NBIMyFTSE_exit_vs_nonNBIM = 1 if FTSE_exit2 == 1 & NBIM_exit_vs_nonNBIM == 1
by ISIN: replace NBIMnoFTSE_exit_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0  & NBIM[_n-2] == 0 
by ISIN: replace NBIMyFTSE_exit_vs_nonNBIM = 0 if NBIM == 0 & NBIM[_n-1] == 0  & NBIM[_n+1] == 0  & NBIM[_n-2] == 0 

by ISIN: gen NBIM_exit_vs_NBIM = 1 if NBIM_exit_vs_nonNBIM == 1
gen NBIMnoFTSE_exit_vs_NBIM = NBIM_exit_vs_NBIM
by ISIN: replace NBIM_exit_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1 
replace NBIMnoFTSE_exit_vs_NBIM = . if FTSE_exit2 == 1 
gen NBIMyFTSE_exit_vs_NBIM = 1 if FTSE_exit2 == 1 & NBIM_exit_vs_NBIM == 1
by ISIN: replace NBIMnoFTSE_exit_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1 
by ISIN: replace NBIMyFTSE_exit_vs_NBIM = 0 if NBIM == 1 & NBIM[_n-1] == 1 & NBIM[_n+1] == 1 & NBIM[_n-2] == 1 

by ISIN: gen NBIM_exit_vs_ALL = 1 if NBIM_exit_vs_nonNBIM == 1
gen NBIMnoFTSE_exit_vs_ALL = NBIM_exit_vs_ALL
replace NBIMnoFTSE_exit_vs_ALL = . if FTSE_exit2 == 1 
replace NBIM_exit_vs_ALL = 0 if NBIM_exit_vs_NBIM == 0 | NBIM_exit_vs_nonNBIM == 0 
gen NBIMyFTSE_exit_vs_ALL = 1 if FTSE_exit2 == 1 & NBIM_exit_vs_ALL == 1
replace NBIMnoFTSE_exit_vs_ALL = 0 if NBIM_exit_vs_NBIM == 0 | NBIM_exit_vs_nonNBIM == 0 
replace NBIMyFTSE_exit_vs_ALL = 0 if NBIM_exit_vs_NBIM == 0 | NBIM_exit_vs_nonNBIM == 0 
*/

*********************************************************************************************************************************
* Table IA.XV. Number of firms that enter and exit the NBIM portfolio every year: Table to see discretionary entries and exits	*
*********************************************************************************************************************************
tab year NBIM_exit if year > 2008 & year < 2015
tab year NBIM_entry if year > 2008 & year < 2015
tab year NBIM_exit if NBIMnoFTSE_exit_vs_ALL == 1 & year > 2008 & year < 2015 // discretionary 
tab year NBIM_entry if NBIMnoFTSE_entry_vs_ALL == 1 & year > 2008 & year < 2015 // discretionary


*local refyear = 2009
local maxYear = 2014
forval i = `refyear'/`maxYear' {
	gen NBIM_exit_vs_nonNBIMyear`i' = NBIM_exit_vs_nonNBIM * yeardummy`i'
	gen NBIM_exit_vs_NBIMyear`i' = NBIM_exit_vs_NBIM * yeardummy`i'
	gen NBIM_exit_vs_ALLyear`i' = NBIM_exit_vs_ALL * yeardummy`i'
	gen NBIM_entry_vs_nonNBIMyear`i' = NBIM_entry_vs_nonNBIM * yeardummy`i'
	gen NBIM_entry_vs_NBIMyear`i' = NBIM_entry_vs_NBIM * yeardummy`i'
	gen NBIM_entry_vs_ALLyear`i' = NBIM_entry_vs_ALL * yeardummy`i'
}

gen NBIMPost = NBIM * Post
gen NBIM_exit_vs_nonNBIMPost = NBIM_exit_vs_nonNBIM * Post
gen NBIM_exit_vs_NBIMPost = NBIM_exit_vs_NBIM * Post
gen NBIM_exit_vs_ALLPost = NBIM_exit_vs_ALL * Post
gen NBIM_entry_vs_nonNBIMPost = NBIM_entry_vs_nonNBIM * Post
gen NBIM_entry_vs_NBIMPost = NBIM_entry_vs_NBIM * Post
gen NBIM_entry_vs_ALLPost = NBIM_entry_vs_ALL * Post

label var NBIM_exit_vs_nonNBIMPost "NBIM_exit_vs_nonNBIM*Post"
label var NBIM_exit_vs_NBIMPost "NBIM_exit_vs_NBIM*Post"
label var NBIM_exit_vs_ALLPost "NBIM_exit_vs_ALL*Post"
label var NBIM_entry_vs_nonNBIMPost "NBIM_entry_vs_nonNBIM*Post"
label var NBIM_entry_vs_NBIMPost "NBIM_entry_vs_NBIM*Post"
label var NBIM_entry_vs_ALLPost "NBIM_entry_vs_ALL*Post"

forval i = `refyear'/`maxYear' {
	label var NBIM_exit_vs_nonNBIMyear`i' "NBIMexitvsnonNBIM*yeardummy`i'"
	label var NBIM_exit_vs_NBIMyear`i' "NBIMexitvsNBIM*yeardummy`i'"
	label var NBIM_exit_vs_ALLyear`i' "NBIMexitvsALL*yeardummy`i'"
	label var NBIM_entry_vs_nonNBIMyear`i' "NBIMentryvsnonNBIM*yeardummy`i'"	
	label var NBIM_entry_vs_NBIMyear`i' "NBIMentryvsNBIM*yeardummy`i'"
	label var NBIM_entry_vs_ALLyear`i' "NBIMentryvsALL*yeardummy`i'"	
}
replace NBIM_exit_vs_nonNBIMyear`refyear' = 0
replace NBIM_exit_vs_NBIMyear`refyear' = 0
replace NBIM_exit_vs_ALLyear`refyear' = 0
replace NBIM_entry_vs_nonNBIMyear`refyear' = 0
replace NBIM_entry_vs_NBIMyear`refyear' = 0
replace NBIM_entry_vs_ALLyear`refyear' = 0

/*
*************************************************************************************
* Table IA.XIV. Average governance for firms that enter and exit the NBIM portfolio	*
*************************************************************************************

* Panel A
putexcel set "$outputtex/tables/EntryExitGovernance_A.xlsx", replace
putexcel A2 = "AVERAGE GOVERNANCE SCORE", bold
putexcel B4 = "PRE"
putexcel B5 = "POST"
putexcel C3 = "Non NBIM"
putexcel D3 = "NBIM"
putexcel E3 = "EXIT"
putexcel F3 = "ENTRY"

tabstat ManagementScore if NBIM == 0 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat NonNBIMPre = r(StatTotal)
putexcel c4 = matrix(NonNBIMPre), nformat(number_d2) 
tabstat ManagementScore if NBIM == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat NBIMPre = r(StatTotal)
putexcel d4 = matrix(NBIMPre), nformat(number_d2) 
tabstat ManagementScore if NBIM_exit == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat ExitPre = r(StatTotal)
putexcel e4 = matrix(ExitPre), nformat(number_d2) 
tabstat ManagementScore if NBIM_entry == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat EntryPre = r(StatTotal)
putexcel f4 = matrix(EntryPre), nformat(number_d2)

tabstat ManagementScore if NBIM == 0 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat NonNBIMPost = r(StatTotal)
putexcel c5 = matrix(NonNBIMPost), nformat(number_d2) 
tabstat ManagementScore if NBIM == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat NBIMPost = r(StatTotal)
putexcel d5 = matrix(NBIMPost), nformat(number_d2) 
tabstat ManagementScore if NBIM_exit == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat ExitPost = r(StatTotal)
putexcel e5 = matrix(ExitPost), nformat(number_d2) 
tabstat ManagementScore if NBIM_entry == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat EntryPost = r(StatTotal)
putexcel f5 = matrix(EntryPost), nformat(number_d2) 

preserve
* Panel B
replace ManagementScore = ManagementScorefixed2011
putexcel set "$outputtex/tables/EntryExitGovernance_B.xlsx", replace
putexcel A2 = "AVERAGE GOVERNANCE SCORE", bold
putexcel B4 = "PRE"
putexcel B5 = "POST"
putexcel C3 = "Non NBIM"
putexcel D3 = "NBIM"
putexcel E3 = "EXIT"
putexcel F3 = "ENTRY"

tabstat ManagementScore if NBIM == 0 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat NonNBIMPre = r(StatTotal)
putexcel c4 = matrix(NonNBIMPre), nformat(number_d2) 
tabstat ManagementScore if NBIM == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat NBIMPre = r(StatTotal)
putexcel d4 = matrix(NBIMPre), nformat(number_d2) 
tabstat ManagementScore if NBIM_exit == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat ExitPre = r(StatTotal)
putexcel e4 = matrix(ExitPre), nformat(number_d2) 
tabstat ManagementScore if NBIM_entry == 1 & year >2008 & year < 2012 & outlier == 0, stat(mean) save
mat EntryPre = r(StatTotal)
putexcel f4 = matrix(EntryPre), nformat(number_d2)

tabstat ManagementScore if NBIM == 0 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat NonNBIMPost = r(StatTotal)
putexcel c5 = matrix(NonNBIMPost), nformat(number_d2) 
tabstat ManagementScore if NBIM == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat NBIMPost = r(StatTotal)
putexcel d5 = matrix(NBIMPost), nformat(number_d2) 
tabstat ManagementScore if NBIM_exit == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat ExitPost = r(StatTotal)
putexcel e5 = matrix(ExitPost), nformat(number_d2) 
tabstat ManagementScore if NBIM_entry == 1 & year > 2011 & year < 2015 & outlier == 0, stat(mean) save
mat EntryPost = r(StatTotal)
putexcel f5 = matrix(EntryPost), nformat(number_d2) 
restore
*/



* Entry & Exit with Dependent Variable = Entry or Exit 
local KEEP_VARS "PostManagementScorefixed2011 ManagementScorefixed2011"

* Logit with odds ratios
* In entry & exit analyses I do not impose full panel (outlierSCORE == 0), because if not sample is too small & MagScore is not the dep variable, so need to impose full panel

*********************************************************************************
* Table 9. Governance differences for firms that enter the portfolio of NBIM	*
*********************************************************************************
quietly logit NBIM_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIM_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMnoFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMnoFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMyFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMyFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_entry_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)

*********************************************************************************
* Table 10. Governance differences for firms that exit the portfolio of NBIM	*
*********************************************************************************

quietly logit NBIM_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIM_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMyFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMyFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)



* Logit and predicted probabilities
*********************************************************************************************
* Table IA.XIII. Panel A: Governance differences for firms that enter the portfolio of NBIM	*
*********************************************************************************************

quietly logit NBIM_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIM_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	e(r2_p) 
quietly logit NBIMnoFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIMnoFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	 e(r2_p)
quietly logit NBIMyFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIMyFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_entry2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	 e(r2_p)

*********************************************************************************************
* Table IA.XIII. Panel B: Governance differences for firms that enter the portfolio of NBIM	*
*********************************************************************************************

quietly logit NBIM_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIM_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMnoFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMnoFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMyFTSE_entry_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMyFTSE_entry_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_entry_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	



*********************************************************************************************
* Table IA.XVI. Panel A: Governance differences for firms that exit the portfolio of NBIM	*
*********************************************************************************************
quietly logit NBIM_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIM_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	e(r2_p)
quietly logit NBIMyFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4) e(r2_p)
quietly logit NBIMyFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id)  
predict proby, pr
summarize proby
drop proby
outreg2 using "$outputtex/tables/NBIM_exit2.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(4)	e(r2_p)


*********************************************************************************************
* Table IA.XVI. Panel B: Governance differences for firms that exit the portfolio of NBIM	*
*********************************************************************************************
quietly logit NBIM_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIM_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMnoFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMnoFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMyFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMyFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)
*/



preserve
drop if year == 2011

*********************************************************************************************
* Table IA.XVII Panel A: Governance differences for firms that exit the portfolio of NBIM	*
*********************************************************************************************
quietly logit NBIM_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIM_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMnoFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)
quietly logit NBIMyFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or 
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3) eform e(r2_p)
quietly logit NBIMyFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy*  if outlier == 0 & outlieryeardummies == 0 , vce(cl id) or
outreg2 using "$outputtex/tables/NBIM_exit_odds.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)	eform e(r2_p)


*********************************************************************************************
* Table IA.XVII Panel B: Governance differences for firms that exit the portfolio of NBIM	*
*********************************************************************************************
quietly logit NBIM_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", replace nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIM_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMnoFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMnoFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)	
quietly logit NBIMyFTSE_exit_vs_nonNBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NonNBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5) 
quietly logit NBIMyFTSE_exit_vs_NBIM PostManagementScorefixed2011 ManagementScorefixed2011 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 , vce(cl id) 
quietly margins, dydx(PostManagementScorefixed2011 ManagementScorefixed2011) atmeans post
outreg2 using "$outputtex/tables/NBIM_exit_MF.doc", nocons tex(frag) label ctitle("Vs-NBIM") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(5)
*/

restore

save "$CAPAPE\DATA\RAW_DATA\Alphas\NBIMentryexit.dta", replace



***************************************************************
******* Run regressions for Intent to treat analysis **********
***************************************************************

use "$CAPAPE\DATA\RAW_DATA\Alphas\NBIMentryexit.dta", clear

sort ISIN year
gen excludedethics2011 = (excluded_ethics == 1 & year == 2011)
by ISIN: egen excluded_ethics2011 = max(excludedethics2011)
drop excludedethics2011
gen excludedethics2010 = (excluded_ethics == 1 & year == 2010)
by ISIN: egen excluded_ethics2010 = max(excludedethics2010)
drop excludedethics2010

gen NBIMFTSE2011 = (FTSE_2011 == 1 & NBIM_2011 == 1 & excluded_ethics2011 ==0)
gen NBIMFTSE2010 = (FTSE_2010 == 1 & NBIM_2010 == 1 & excluded_ethics2010 ==0)
gen onlyFTSEorEthics2011 = (FTSE_2011 == 1 & NBIM_2011 == 0 & excluded_ethics2011 == 1)
gen onlyFTSE2011 = (FTSE_2011 == 1 & NBIM_2011 == 0 & excluded_ethics2011 ==0)
gen onlyFTSE2010 = (FTSE_2010 == 1 & NBIM_2010 == 0 & excluded_ethics2010 ==0)
gen onlyNBIM2011 = (FTSE_2011 == 0 & NBIM_2011 == 1 & excluded_ethics2011 ==0)
gen onlyNBIM2010 = (FTSE_2010 == 0 & NBIM_2010 == 1 & excluded_ethics2010 ==0)
gen nonNBIMFTSE2010 = (FTSE_2010 == 0 & NBIM_2010 == 0 & excluded_ethics2010 ==0)
gen nonNBIMFTSE2011 = (FTSE_2011 == 0 & NBIM_2011 == 0 & excluded_ethics2011 ==0)
gen NBIMentrypost2011 = (NBIM_2012 == 1 & NBIM_2011 == 0 | NBIM_2013 == 1 & NBIM_2011 == 0 | NBIM_2014 == 1 & NBIM_2011 == 0 | NBIM_2015 == 1 & NBIM_2011 == 0)
gen onlyFTSE2011entrypost = onlyFTSE2011 * NBIMentrypost2011
gen onlyFTSE2011neverentry = (onlyFTSE2011 == 1 & NBIMentrypost2011 == 0)
rename FTSE_2011 FTSE2011 
rename FTSE_2010 FTSE2010 
gen PostonlyFTSE2011 = Post * onlyFTSE2011
gen PostonlyNBIM2011 = Post * onlyNBIM2011
gen PostNBIMFTSE2011 = Post * NBIMFTSE2011
gen Postexcludedethics = Post * excluded_ethics
gen Postexcludedethics2011 = Post * excluded_ethics2011
gen PostnonNBIMFTSE2011 = Post * nonNBIMFTSE2011
gen PostFTSE2011 = Post * FTSE2011
gen PostNBIM2011 = Post*NBIM_2011
gen PostFTSE_percfixed2011 = Post*FTSE_percfixed2011
label var PostFTSE_percfixed2011 "Post*FTSE(%)2011"

gen OnlyFTSE_percfixed2011nozero = (FTSE_percfixed2011) if onlyFTSE2011 == 1

gen PostonlyFTSE2010 = Post * onlyFTSE2010
gen PostonlyNBIM2010 = Post * onlyNBIM2010
gen PostNBIMFTSE2010 = Post * NBIMFTSE2010
gen Postexcludedethics2010 = Post * excluded_ethics2010
gen PostFTSE2010 = Post * FTSE2010
gen PostNBIM2010 = Post*NBIM_2010

gen PostonlyFTSE2011entrypost = Post * onlyFTSE2011entrypost
gen PostonlyFTSE2011neverentry = Post * onlyFTSE2011neverentry
gen PostonlyFTSEorEthics2011 = Post * onlyFTSEorEthics2011

gen PostNBIMrelev = Post*NBIM
*replace PostNBIMrelev = 0 if PostNBIMrelev == .

forval i = 2006/2015 {
	gen NBIMrelevyear`i' = NBIM * yeardummy`i'
}


*************************************************
* Table IA.7 First stage: relevance of NBIM2011	*
*************************************************
local KEEP_VARS "treat NBIM* Treat* PostNBIM* Posttreat"

quietly reg PostNBIMrelev yeardummy* Postcountry_dummy* Posttreat if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, nocons vce(cl id)
outreg2 using "$outputtex/tables/relevance.doc", replace nocons tex(frag) label ctitle("Relevance") keep(`KEEP_VARS') dec(3)
quietly reg PostNBIMrelev yeardummy* Postcountry_dummy* Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, nocons vce(cl id)
outreg2 using "$outputtex/tables/relevance.doc", nocons tex(frag) label ctitle("Relevance with YD") keep(`KEEP_VARS') dec(3)

***********************************************************************************
*** Table 4: Effect of NBIM on governance: instrumental variables 2SLS analysis ***
***********************************************************************************
local CONTROL_VARS "TotalAssets CapitalStructure ROA Institutional_investors_total"
local KEEP_VARS "Posttreat NBIM* Treat* PostNBIM*"
quietly reg ManagementScore yeardummy* Postcountry_dummy* treat Posttreat  if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , vce(cl id)
outreg2 using "$outputtex/tables/2SLS.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
quietly reghdfe ManagementScore yeardummy* Postcountry_dummy* Posttreat  if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
outreg2 using "$outputtex/tables/2SLS.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
quietly xtivreg ManagementScore yeardummy* Postcountry_dummy*  (PostNBIMrelev = Posttreat) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first vce(cl id)
outreg2 using "$outputtex/tables/2SLS.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
quietly xtivreg ManagementScore yeardummy* Postcountry_dummy*  (PostNBIMrelev = Posttreat) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
quietly xtivreg ManagementScore yeardummy*  Postcountry_dummy* NBIMrelevyear2009 NBIMrelevyear2010 NBIMrelevyear2011 (NBIMrelevyear2012 NBIMrelevyear2013 NBIMrelevyear2014 NBIMrelevyear2015 = Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)

*********************************************************************************************
* Table IA.8 The effect of NBIM on firm governance: instrumental variables (2006-2015)		*
*********************************************************************************************

local KEEP_VARS "Posttreat NBIM* Treat* PostNBIM*"
replace yeardummy`refyear' = (year == `refyear')
replace NBIMrelevyear`refyear' = NBIM * yeardummy`refyear'
replace NBIMrelevyear2006 = 0
reg ManagementScore yeardummy* Postcountry_dummy* treat Posttreat  if outlier == 0 & outlierSCORE == 0 , vce(cl id)
outreg2 using "$outputtex/tables/2SLS_robust.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
reghdfe ManagementScore yeardummy* Postcountry_dummy* Posttreat  if outlier == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
outreg2 using "$outputtex/tables/2SLS_robust.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
xtivreg ManagementScore yeardummy* Postcountry_dummy* (PostNBIMrelev = Posttreat) if outlier == 0 & outlierSCORE == 0, first vce(cl id)
outreg2 using "$outputtex/tables/2SLS_robust.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
xtivreg ManagementScore yeardummy* Postcountry_dummy* (PostNBIMrelev = Posttreat) if outlier == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS_robust.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
xtivreg ManagementScore yeardummy* Postcountry_dummy* NBIMrelevyear2006 NBIMrelevyear2007 NBIMrelevyear2008 NBIMrelevyear2009 NBIMrelevyear2010 NBIMrelevyear2011 (NBIMrelevyear2012 NBIMrelevyear2013 NBIMrelevyear2014 NBIMrelevyear2015 = Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015) if outlier == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS_robust.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
replace yeardummy`refyear' = 0
replace NBIMrelevyear`refyear' = 0


* Placebo tests: change the Post variable to 2009 or 2010
*********************************************************************
* Table IA.9 The effect of NBIM on firm governance: Placebo Tests	*
*********************************************************************
preserve

gen treat8 = (NBIM_2008)
gen treat9 = (NBIM_2009)
gen Post10 = (year >= 2010)
gen Post9 = (year >= 2009)
gen Post9treat8 = Post9*treat8
gen Post10treat9 = Post10*treat9

forval i = 1/67 {
	gen Post10country_dummy`i' = Post10 * country_dummy`i'
	gen Post9country_dummy`i' = Post9 * country_dummy`i'
}

forval i = 9/10 {
	gen Post`i'NBIMrelev = Post`i'*NBIM
	gen Post`i'treat = Post`i'*treat
}

local KEEP_VARS "Post9treat8 Post10treat9 Post9NBIM* Post10NBIM*"
reghdfe ManagementScore yeardummy* Post9country_dummy* Post9treat8 if outlier == 0 & year < 2012 & outlierSCORE == 0 , abs(id) vce(cl id)
outreg2 using "$outputtex/tables/placebo.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
reghdfe ManagementScore yeardummy* Post10country_dummy* Post10treat9 if outlier == 0 & year < 2012 & outlierSCORE == 0 , abs(id) vce(cl id)
outreg2 using "$outputtex/tables/placebo.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
xtivreg ManagementScore yeardummy* Post9country_dummy* (Post9NBIMrelev = Post9treat8) if outlier == 0 & year < 2012 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/placebo.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
xtivreg ManagementScore yeardummy* Post10country_dummy* (Post10NBIMrelev = Post10treat9) if outlier == 0 & year < 2012 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/placebo.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)

restore



* Create additional variables
foreach option of local firmfund{
	bysort year: egen quintNBIM_`option'_percfixed2011 = xtile(NBIM_`option'_percfixed2011), nq(2) 
	gen PostquintNBIM_`option'_percfixed2011 = Post * quintNBIM_`option'_percfixed2011
	label var PostquintNBIM_`option'_percfixed2011 "Post*Quantile-NBIM`option'(%)2011"
}
gen EBITDAoverRev = EBITDAoverRevenue
gen ManagementSc = ManagementScore

* Create quantiles for different firm characteristics
local vars "var minorityinvs TotalAssets TotalRevenue MV performance EBITDAoverRev ManagementSc liquidity age2011" // 
local NQ = 4
foreach option of local vars{
	gen Posttreat`option' = Post * `option' * treat
	gen treat`option' = `option' * treat
	gen Post`option' = Post * `option' 
	sort ISIN year
	egen Mean_`option' = mean(`option') if year == 2011, by(ISIN) 
	xtile Quantilem_`option' = `option' if outlier == 0 & outlieryeardummies == 0 & year == 2011, n(`NQ') 
	egen Quantile_`option' = mean(Quantilem_`option'), by(ISIN)
	tab Quantile_`option', gen (Quantile_`option'_qdummy_)
	forval i=1/`NQ' {
		gen PostTQ_`option'_qdummy_`i' = Post * Quantile_`option'_qdummy_`i' * treat
		gen PostQ_`option'_qdummy_`i' = Post * Quantile_`option'_qdummy_`i' 
		label var PostTQ_`option'_qdummy_`i' "Post*NBIM*NBIM`option'quantile`i'"
	}
	drop Quantilem_`option' 
}

/* We do an adjustment because for country quantiles: USA and Canada have same investor protection grade in 2011 (83.3) and in number of observations they represent almost 33% of the sample firms. The quantile code groups them in same quantile, I undo this to have similar number of observations in all quantiles and put Canada in quantile 4 (and keep USA in quantile 3) because Canada in 2013 rises grade to 86.6 whilst USA stays in 83.3. With this change, quantiles have more similar amount of obsefvations.
*/
replace PostTQ_minorityinvs_qdummy_4 = 1 if PostTQ_minorityinvs_qdummy_3 == 1 & Country == "Canada"
replace PostTQ_minorityinvs_qdummy_3 = 0 if PostTQ_minorityinvs_qdummy_3 == 1 & Country == "Canada"
replace PostQ_minorityinvs_qdummy_4 = 1 if PostQ_minorityinvs_qdummy_3 == 1 & Country == "Canada"
replace PostQ_minorityinvs_qdummy_3 = 0 if PostQ_minorityinvs_qdummy_3 == 1 & Country == "Canada"


* Create quantiles for FTSE, fund_perc and firm_perc
local firmfund "FTSE OnlyFTSE NBIM_firm NBIM_fund"
local NQ = 4
foreach option of local firmfund{
	xtile `option'_perc2011_quantm = `option'_percfixed2011nozero if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 & year == 2011, n(`NQ') 
	sort ISIN year
	egen `option'_perc2011_quant = mean(`option'_perc2011_quantm), by(ISIN)
	tab `option'_perc2011_quant, gen (`option'_perc2011_qdummy_)
	gen `option'_perc2011_qdummy_0 = (`option'_percfixed2011 == 0)
	forval i=1/`NQ' {
		replace `option'_perc2011_qdummy_`i' = 0 if `option'_perc2011_qdummy_0 == 1
	}
	forval i=0/`NQ' {
		replace `option'_perc2011_qdummy_`i' = 0 if `option'_perc2011_qdummy_0 == 1
		gen Post`option'_perc2011_qdummy_`i' = Post * `option'_perc2011_qdummy_`i'
		label var Post`option'_perc2011_qdummy_`i' "Post*`option'quantile`i'"
	}
	drop `option'_perc2011_quantm // `option'_perc2011_qdummy_* 
	replace Post`option'_perc2011_qdummy_0 = 0 
}


forval i=0/`NQ' {
replace PostOnlyFTSE_perc2011_qdummy_`i' = 0 if PostOnlyFTSE_perc2011_qdummy_`i' == .
}

*********************************************************************************
*  					Table 5. Speed of provisions									*
*********************************************************************************

* Eliminate all easy and medium provisions (provisions that are about policy, reporting and compensation), so I eliminate 15 provisions that are easy to change

egen SlowIndex19 = rowtotal( NominationCommitteeInvolv BoardSizeMore10Less8 BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg   ExecutivsGenderDiversPerc  BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers   CompensCommittMgtIndep  AuditCommitteeIndep    IndependentBoardMembers   auditcommitteemgtindep  BoardSpecificSkills CEOChairmanSeparation BoardIndividualReelection    ExternalConsultants), missing  

egen SlowIndexnonmissing19 =  rownonmiss( NominationCommitteeInvolv BoardSizeMore10Less8 BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg   ExecutivsGenderDiversPerc  BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers  CompensCommittMgtIndep  AuditCommitteeIndep    IndependentBoardMembers   auditcommitteemgtindep  BoardSpecificSkills CEOChairmanSeparation BoardIndividualReelection     ExternalConsultants   ) // Add all existing (nonmissing) provisions to use as denominator in equally weighted index

replace SlowIndex19 = (SlowIndex19 / SlowIndexnonmissing19)*100 // Equally weighted sum of the existing (nonmissing) provisions that the company has, index is between 0 and 100

 xtivreg SlowIndex19 yeardummy*  Postcountry_dummy* NBIMrelevyear2009 NBIMrelevyear2010 NBIMrelevyear2011 (NBIMrelevyear2012 NBIMrelevyear2013 NBIMrelevyear2014 NBIMrelevyear2015 = Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS_Fast.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(NBIM*) dec(3)


* We construct out of sample volatility for each provision to measure which provisions are easier to change (we consider that those that are more volatile, are easier to change)

local vars "auditcommitteemgtindep  AuditCommitteeIndep BoardAttendance BoardBackgroundandSkills BoardCulturalDiversity BoardFunctionsPolicy BoardIndividualReelection BoardMeetingAttendanceAvg BoardMemberAffiliations BoardSizeMore10Less8 BoardSpecificSkills BoardStructurePolicy CEOCompensatLinktoTSR CEOChairmanSeparation CompensationCommitteeIndep CompensCommittMgtIndep CompensationImprovTools ExecutiveCompensPolicy ExecutiveIndivCompens FemaleonBoard IndependentBoardMembers InternalAuditDepartReport NominationCommitteeIndep NominationCommitteeInvolv NonExecutiveBoardMembers SharehApprovalStockComp ExecutivsGenderDiversPerc SuccessionPlan SustainabCompensIncentives executivecompensationltobj ExperienceBoard ExternalConsultants HighestRemunerationPackag TotalSeniorExecCompens" 

foreach var of local vars {
	egen `var'_std = sd(`var') if outlier == 0 & outlierSCORE == 0 & year < 2012 , by(id) // calculate the std deviation for each provision by firm
	egen `var'_AV = mean(`var'_std) if outlier == 0 & outlierSCORE == 0  & year < 2012  // calculate the average std deviation for each provision (to measure easy to change)
}


* Exclude the top quartile of fast moving provisions: there are 34, so we exclude the 8 fastest provisions
egen SlowIndex26 = rowtotal(InternalAuditDepartReport NominationCommitteeInvolv BoardSizeMore10Less8 BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg TotalSeniorExecCompens ExecutiveCompensPolicy ExecutivsGenderDiversPerc ExecutiveIndivCompens BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers BoardStructurePolicy  CompensCommittMgtIndep executivecompensationltobj AuditCommitteeIndep  HighestRemunerationPackag CEOCompensatLinktoTSR IndependentBoardMembers CompensationImprovTools BoardFunctionsPolicy auditcommitteemgtindep BoardBackgroundandSkills), missing  

egen SlowIndexnonmissing26 =  rownonmiss(InternalAuditDepartReport NominationCommitteeInvolv  BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg TotalSeniorExecCompens ExecutiveCompensPolicy ExecutivsGenderDiversPerc ExecutiveIndivCompens BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers BoardStructurePolicy  CompensCommittMgtIndep executivecompensationltobj AuditCommitteeIndep  HighestRemunerationPackag CEOCompensatLinktoTSR IndependentBoardMembers CompensationImprovTools BoardFunctionsPolicy auditcommitteemgtindep BoardBackgroundandSkills)

replace SlowIndex26 = (SlowIndex26 / SlowIndexnonmissing26)*100 // Equally weighted sum of the existing (nonmissing) provisions that the company has, index is between 0 and 100

xtivreg SlowIndex26 yeardummy*  Postcountry_dummy* NBIMrelevyear2009 NBIMrelevyear2010 NBIMrelevyear2011 (NBIMrelevyear2012 NBIMrelevyear2013 NBIMrelevyear2014 NBIMrelevyear2015 = Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS_Fast.doc",  nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(NBIM*) dec(3)


* Exclude the top tercile of fast moving provisions: there are 34, so we exclude the 11 fastest provisions

egen SlowIndex23 = rowtotal(InternalAuditDepartReport NominationCommitteeInvolv BoardSizeMore10Less8 BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg TotalSeniorExecCompens ExecutiveCompensPolicy ExecutivsGenderDiversPerc ExecutiveIndivCompens BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers BoardStructurePolicy  CompensCommittMgtIndep executivecompensationltobj AuditCommitteeIndep  HighestRemunerationPackag CEOCompensatLinktoTSR IndependentBoardMembers CompensationImprovTools), missing  

egen SlowIndexnonmissing23 =  rownonmiss(InternalAuditDepartReport NominationCommitteeInvolv BoardSizeMore10Less8 BoardMemberAffiliations NominationCommitteeIndep FemaleonBoard BoardMeetingAttendanceAvg TotalSeniorExecCompens ExecutiveCompensPolicy ExecutivsGenderDiversPerc ExecutiveIndivCompens BoardCulturalDiversity CompensationCommitteeIndep ExperienceBoard  NonExecutiveBoardMembers BoardStructurePolicy  CompensCommittMgtIndep executivecompensationltobj AuditCommitteeIndep  HighestRemunerationPackag CEOCompensatLinktoTSR IndependentBoardMembers CompensationImprovTools) 

replace SlowIndex23 = (SlowIndex23 / SlowIndexnonmissing23)*100 // Equally weighted sum of the existing (nonmissing) provisions that the company has, index is between 0 and 100

quietly xtivreg SlowIndex23 yeardummy*  Postcountry_dummy* NBIMrelevyear2009 NBIMrelevyear2010 NBIMrelevyear2011 (NBIMrelevyear2012 NBIMrelevyear2013 NBIMrelevyear2014 NBIMrelevyear2015 = Treat_yeardummy2012 Treat_yeardummy2013 Treat_yeardummy2014 Treat_yeardummy2015) if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, first fe vce(cl id)
outreg2 using "$outputtex/tables/2SLS_Fast.doc", nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(NBIM*) dec(3)


*************************************************************************************
* Table 6. The effect of NBIM on firm governance – Extensive vs. Intensive margin	*
*************************************************************************************
local KEEP_VARS "PostNBIM_fund_percfixed2011 PostFTSE* PostNBIM_firm_percfixed2011 PostNBIM_firm_perc2011_qdummy_* PostNBIM_fund_perc2011_qdummy_* PostNBIM*" 
local YLIST "Management" 
foreach Y of local YLIST {
	quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM_fund_percfixed2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_`Y'.doc", replace nocons tex(frag) label ctitle("Fund") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM_firm_percfixed2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_`Y'.doc", nocons tex(frag) label ctitle("Firm") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM_fund_percfixed2011 PostNBIM_firm_percfixed2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_`Y'.doc", nocons tex(frag) label ctitle("All") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM_fund_perc2011_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_`Y'.doc", nocons tex(frag) label ctitle("Dum") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	* To interpret Wald tests: https://www.stata.com/manuals13/rtest.pdf // see example 3
	test _b[PostNBIM_fund_perc2011_qdummy_4] = _b[PostNBIM_fund_perc2011_qdummy_1]

	quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM_firm_perc2011_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_`Y'.doc", nocons tex(frag) label ctitle("Dum") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	test _b[PostNBIM_firm_perc2011_qdummy_4] = _b[PostNBIM_firm_perc2011_qdummy_1]
	* Result: Prob > F =    0.0091 We find that we can reject the equality hypothesis at the 1% level. Thus, the coefs are different.
}

*****************************************************************************
* Table 7. The effect of NBIM on firm governance – Heterogeneous effects	*
*****************************************************************************
replace Postcountry_dummy1 = 0 // to avoid colinearity with PostQ_dummies
local vars "var minorityinvs TotalAssets TotalRevenue MV EBITDAoverRev ManagementSc liquidity age2011"
foreach var of local vars{
	replace PostQ_`var'_qdummy_1 = 0
}
local KEEP_VARS "PostTQ_*"
local YLIST "Management"
foreach Y of local YLIST {
	quietly reghdfe `Y'Score Postcountry_dummy* yeardummy* PostQ_TotalAssets_qdummy_* PostTQ_TotalAssets_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", replace nocons tex(frag) label ctitle("Assets") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score Postcountry_dummy* yeardummy* PostQ_MV_qdummy_*  PostTQ_MV_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", nocons tex(frag) label ctitle("MV") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score Postcountry_dummy* yeardummy* PostQ_EBITDAoverRev_qdummy_*  PostTQ_EBITDAoverRev_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", nocons tex(frag) label ctitle("Perf") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score Postcountry_dummy* yeardummy* PostQ_liquidity_qdummy_* PostTQ_liquidity_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", nocons tex(frag) label ctitle("Liq") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score Postcountry_dummy* yeardummy* PostQ_ManagementSc_qdummy_*  PostTQ_ManagementSc_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", nocons tex(frag) label ctitle("Gov") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
	quietly reghdfe `Y'Score yeardummy* PostQ_minorityinvs_qdummy_* PostTQ_minorityinvs_qdummy_* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id)
	outreg2 using "$outputtex/tables/resultsQ_vars.doc", nocons tex(frag) label ctitle("INV") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(2)
}


*********************************************************************************
* Table 8. The effect of NBIM on firm governance – discretionary investments	*
*********************************************************************************
local KEEP_VARS "Post NBIM_firm_perc* NBIM* Treat* PostNBIM_firm_perc* NBIM_fund_perc* PostNBIM_fund_perc* Postonly* Poste* PostN* PostF* Posttreat treat Treat_yeardummy* NBIM_2010_yeardummy*" 
local SORT_VARS "Post Posttreat treat PostFTSE2011 PostonlyNBIM2011 PostNBIMFTSE2011 PostonlyFTSE2011 Postexcludedethics2011 yeardummy* NBIM_hold_perc_yeardummy* treat_yeardummy* TotalRevenue TotalAssets performance CapitalStructure LTDebtoverTotalLiabs EBITDAoverRevenue Institutional_investors_total Post*"
local YLIST "Management" 
foreach Y of local YLIST {
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* Posttreat if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy*  PostFTSE2011 if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE2") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy*  PostFTSE2011 Posttreat if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE3") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy*  PostonlyNBIM2011 PostonlyFTSE2011 PostNBIMFTSE2011 Postexcludedethics2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)  
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE4") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
}


*********************************************************************************************************************************************
*********************************************************************************************************************************************



* Robustness Tables of the ITT Section in the paper	*
*****************************************************************************************
* Table IA10. The effect of NBIM on governance (Investment categories fixed in 2010)	*
*****************************************************************************************

foreach Y of local YLIST {
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostNBIM2010 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
		outreg2 using "$outputtex/tables/results2010_`Y'.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostFTSE2010 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
		outreg2 using "$outputtex/tables/results2010_`Y'.doc", nocons tex(frag) label ctitle("FE2") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostFTSE2010 PostNBIM2010 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
		outreg2 using "$outputtex/tables/results2010_`Y'.doc", nocons tex(frag) label ctitle("FE2") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y'Score yeardummy* Postcountry_dummy* PostonlyNBIM2010 PostonlyFTSE2010 PostNBIMFTSE2010 Postexcludedethics2010 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)
		outreg2 using "$outputtex/tables/results2010_`Y'.doc", nocons tex(frag) label ctitle("FE3") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)

* To test for difference on coefficients: test PostonlyNBIM2011 = PostNBIMFTSE2011: if (Prob > F) <= 0.05, the coefs are significantly different https://www.statalist.org/forums/forum/general-stata-discussion/general/1402910-f-test-for-difference-between-two-coefficients		
* Another test for differences of coefs is lincom: lincom PostNBIMFTSE2011 - PostonlyFTSE2011 (saca un T-stat), más fácil de interpretar
}


*****************************************************************************
* Table IA11 The effect of NBIM on governance in levels – non yearly ranked *
*****************************************************************************
local YLIST "ManagementIndex" 

foreach Y of local YLIST {
		quietly reghdfe `Y' yeardummy* Postcountry_dummy* Posttreat if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y' yeardummy* Postcountry_dummy*  PostFTSE2011 if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0, abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE2") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y' yeardummy* Postcountry_dummy*  PostFTSE2011 Posttreat if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE3") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y' yeardummy* Postcountry_dummy*  PostonlyNBIM2011 PostonlyFTSE2011 PostNBIMFTSE2011 Postexcludedethics2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)  
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE4") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
}	


*************************************************************************************************
* Table IA12 The effect of NBIM on governance in levels – decomposed according to NBIM's Note	*
*************************************************************************************************
local YLIST "IndexNBIMyes IndexNBIMunclear IndexNBIMNo" 

foreach Y of local YLIST {
		quietly reghdfe `Y' yeardummy* Postcountry_dummy* Posttreat if outlier == 0  & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id) 
		outreg2 using "$outputtex/tables/results_`Y'.doc", replace nocons tex(frag) label ctitle("FE") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
		quietly reghdfe `Y' yeardummy* Postcountry_dummy*  PostonlyNBIM2011 PostonlyFTSE2011 PostNBIMFTSE2011 Postexcludedethics2011 if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0 , abs(id) vce(cl id)  
		outreg2 using "$outputtex/tables/results_`Y'.doc", nocons tex(frag) label ctitle("FE4") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
}	



*************************************************************************************
*		 Analyze deltas of governance index vs. deltas of NBIM holdings 			*
*************************************************************************************

sort ISIN year
by ISIN: gen ManagementScorechangef2 = (ManagementScore[_n+2] - ManagementScore)

by ISIN: gen NBIMfirmpercdeltaf1= (NBIM_firm_perc[_n+1] - NBIM_firm_perc)
by ISIN: gen NBIMfundpercdeltaf1=(NBIM_fund_perc[_n+1] - NBIM_fund_perc)
by ISIN: gen NBIMfirmpercdeltaf2=(NBIM_firm_perc[_n+2] - NBIM_firm_perc)
by ISIN: gen NBIMfundpercdeltaf2=(NBIM_fund_perc[_n+2] - NBIM_fund_perc)


gen Post_NBIMfirmpercdeltaf2 = Post * NBIMfirmpercdeltaf2
gen Post_NBIMfundpercdeltaf2 = Post * NBIMfundpercdeltaf2


local KEEP_VARS "Post_* NBIM*"
local SORT_VARS "Post_NBIMfundpercdeltal1 Post_NBIMfirmpercdeltal1 NBIMfundpercdeltal1 NBIMfirmpercdeltal1"


*********************************************************************
* Table A.18. Changes on investment and changes on governance		*
*********************************************************************

reg ManagementScorechangef2 Post_NBIMfundpercdeltaf2 NBIMfundpercdeltaf2 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0
outreg2 using "$outputtex/tables/deltasindexNBIMchangef2Mg.doc", replace nocons tex(frag) label ctitle("Mg-Fund") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)
reg ManagementScorechangef2 Post_NBIMfirmpercdeltaf2 NBIMfirmpercdeltaf2 yeardummy* Postcountry_dummy* if outlier == 0 & outlieryeardummies == 0 & outlierSCORE == 0
outreg2 using "$outputtex/tables/deltasindexNBIMchangef2Mg.doc", nocons tex(frag) label ctitle("Mg-Firm") sortvar(`SORT_VARS') keep(`KEEP_VARS') dec(3)

replace NBIM_fund_perc = NBIM_fund_perc*100
replace NBIM_firm_perc = NBIM_firm_perc*100

by ISIN: replace NBIMfundpercdeltaf1=(NBIM_fund_perc[_n+1] - NBIM_fund_perc)
by ISIN: replace ManagementScorechangef1 = ManagementScore[_n+1] - ManagementScore 

* Check for reverse causality & conduct Granger Causality
tsset id year, yearly

xtset id year
gen Funddelta = NBIMfundpercdeltaf1  
gen Fund = NBIM_fund_perc  
gen Mgdelta = ManagementScorechangef1 
gen MgSc = ManagementScore 


*****************************************************************
* Table A.19. Granger Causality (results appear in log file)	*
*****************************************************************

* In pvargranger causality tests, if "Prob>chi2" is < 0.1 the excluded variable granger causes the equation variable

* 1 lag and deltas after 2011
pvar Mgdelta Funddelta if  outlier == 0 & outlierSCORE == 0 & year>2011 

pvargranger 


* 1 lag and deltas before 2012
pvar Mgdelta Funddelta if  outlier == 0  & outlierSCORE == 0 & year<=2011 & year > 2008 

pvargranger 


